<template>
    
    <!-- 组件的模板 -->
    <div class="page select-approver">
        <div class="weui-cells weui-cells_radio" v-if="data.audit_flag == 1">
            <label class="weui-cell weui-check__label" for="x11" @click="goback(0, '无需审批')">
                <div class="weui-cell__bd">
                    <p>无需审批</p>
                </div>
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" name="radio1" id="x11">
                    <span class="weui-icon-checked"></span>
                </div>
            </label>            
        </div>
        <div class="weui-cells weui-cells_radio">
            <template v-for="item in data.list">
                <label class="weui-cell weui-check__label" :for="x+item.user_id" @click="goback(item.user_id, item.real_name)">
                    <div class="weui-cell__bd">
                        <p>{{item.real_name}}<span class="tag tag_1">{{item.identity_str}}</span></p>
                    </div>
                    <div class="weui-cell__ft">
                        <input type="radio" class="weui-check" name="radio1" :id="x+item.user_id">
                        <span class="weui-icon-checked"></span>
                    </div>
                </label>
            </template>
        </div>
    </div>
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import * as util from 'js/util.js'
    import commonPage from 'clientApi/commonPage.js'
    import widget from 'gapi/widget'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                team_id: 0,
                project_id: 0,
                data: {
                    // "audit_flag" : 1, //1:有 无需审批 的权限 0:没有
                    // "list": [
                    //     {
                    //         "user_id": "4843", //用户id
                    //         "real_name": "王飞", //用户名
                    //         "identity_str": "超级管理员" //身份
                    //     },
                    //     {
                    //         "user_id": "4845",
                    //         "real_name": "鲍莉",
                    //         "identity_str": "管理员"
                    //     }
                    // ]
                },
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                this.team_id = util.getUrddataString('team_id')
                this.project_id = util.getUrddataString('project_id')
                //获取项目超管和管理员列表
                this.getData()
                
            },
            getData(){
                commonPage.loadPageStatus('loading')
                util.ajax({
                    url:'/wage/approve_user/area',
                    type:'GET',
                    data:{
                        team_id: this.team_id,
                        project_id: this.project_id
                    },
                    timeout:10000,
                    success:(result) => {
                        console.log(result)
                        commonPage.loadPageStatus('loadSuccess')
                        if(result&&result.errno == 0){
                            this.data = result.data
                        }else{
                            widget.toast(result.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('服务器异常')
                    },
                    noNetwork: () => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            goback(approve_uid, approve_user_name){
                commonPage.goBack(1, {'approve_uid': approve_uid, 'approve_user_name': approve_user_name})
            }
        },
        created(){

            this.init();
            
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/salary.css"></style>



